import { DynamicService } from './dynamic.service';
import { Controller, Delete, Get, Query } from '@nestjs/common';
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
import { Public } from '@/decorators/visit.decorator';

@ApiTags('后台动态管理')
@Controller('admin/dynamic')
export class DynamicController {
  constructor(private readonly dynammicService: DynamicService) {}

  @Public()
  @ApiOperation({
    summary: '动态查列表询',
  })
  @ApiBearerAuth()
  @Get('/dynamicListSelect')
  dynamicListSelect(
    @Query('page') page = 1,
    @Query('size') size = 10,
    @Query('type') type = 0,
    @Query('content') content = '',
  ) {
    return this.dynammicService.dynamicListSelect({
      page: Number(page),
      size: Number(size),
      type: Number(type),
      content: content,
    });
  }

  @Public()
  @ApiOperation({
    summary: '动态删除',
  })
  @ApiBearerAuth()
  @Delete('/deleteDynamic')
  deleteDynamic(@Query('id') id: number) {
    return this.dynammicService.deleteDynamic(Number(id));
  }
}
